package com.lanswon.qzsmk.controller.inventoryManageController;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lanswon.qzsmk.service.systemManageService.InventoryManagementService;

import ch.qos.logback.classic.Logger;

@Controller
@RequestMapping(value = "/inventoryMagOfReturningByEmp")
public class InventoryMagOfReturningByEmpController {
	
	private final static Logger logger = (Logger) LoggerFactory.getLogger(InventoryMagOfReturningByEmpController.class);
	
	@Autowired
	InventoryManagementService ims;
	
	@RequiresPermissions("inventoryMagOfReturningByEmp:index")
	@RequestMapping(name = "归还卡片页面,inventoryMagOfReturningByEmp:index",value = "/returnCardByEmp", method = { RequestMethod.POST, RequestMethod.GET })
	public String returnCardByEmp(HttpServletRequest request) {
		return "ReturnCardByEmp";
	}
	
	@RequiresPermissions("inventoryMagOfReturningByEmp:saveReturnCardRecords")
	@RequestMapping(name = "归还卡片页面,inventoryMagOfReturningByEmp:saveReturnCardRecords",value="/saveReturnCardRecords",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> saveReturnCardRecords(HttpServletRequest request) throws Exception{
		Map<String, Object> rMap = null;
		rMap = ims.saveReturnCardRecords(request);
		Map<String, Object> map = new HashMap<String,Object>();
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("applyType", rMap.get("credential_type"));
		map.put("ipAddress", rMap.get("ipAddress"));
		map.put("storageNo", rMap.get("storageNo"));
		map.put("max", "true");
		map.put("title", rMap.get("title"));
		map.put("rel", "receiveTask");
		map.put("statusCode", "200");
		map.put("message", "归还成功");
		map.put("param", paramMap);
		map.put("url", "printCredentials/toStoragePdfView");
		
		
		map.put("jumpToTabid", "returnCardByEmp");
		map.put("jumpToUrl", "inventoryMagOfReturningByEmp/returnCardByEmp");
		map.put("jumpToTile", "柜员归还卡片");
		return map;
	}	
}
